#include "stdafx.h"
#include "BridgeWedge.h"

#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <BRepBuilderAPI_Transform.hxx>
DEFINE_CREATE_CLASS(BridgeWedge, "BridgeWedge")
BridgeWedge::BridgeWedge()
{
	InitParam();
}


BridgeWedge::~BridgeWedge()
{
}
void BridgeWedge::InitParam()
{
	AddParam("dx", TYPE_REAL, "150.0");
	AddParam("dy", TYPE_REAL, "281.0");
	AddParam("dz", TYPE_REAL, "294.1");


	AddParam("st", TYPE_REAL, "-0.02");
	AddParam("dirSign", TYPE_INT, "1");

	AddParam("yTop", TYPE_REAL, "160.0");
}

TopoDS_Shape BridgeWedge::CreateShape()
{
	ZMReal dx, dy, dz, yTop, st;
	int dirSign;
	dx = GetParamValue<ZMReal>("dx");
	dy = GetParamValue<ZMReal>("dy");
	dz = GetParamValue<ZMReal>("dz");
	yTop = GetParamValue<ZMReal>("yTop");
	st = GetParamValue<ZMReal>("st");
	dirSign = GetParamValue<int>("dirSign");
	ZMVector<ZMPoint3D> vPnt;
	{
		ZMPoint3D pnt0(0, 0, 0), pnt;
		pnt = pnt0;
		vPnt.push_back(pnt);

		pnt.SetZ(dz);
		vPnt.push_back(pnt);
		
		pnt.SetY(yTop);
		vPnt.push_back(pnt);

		pnt.SetY(dy);
		pnt.SetZ(0);
		vPnt.push_back(pnt);
	}


	TopoDS_Shape shape =  CreatePrismFromPnts(vPnt, ZMPoint3D(1* dirSign, 0, st), dx);
	gp_Trsf t;
	t.SetTranslation(gp_Vec(0, 0, -dz));

	BRepBuilderAPI_Transform tran(t);
	tran.Perform(shape);
	assert(tran.IsDone());

	return tran.Shape();
}
